<template>
    <span>现在时间是:{{now_time}}</span>
</template>

<script>
    export default {
        name: "Test",
        data(){
            return {
              now_time : "NULL",
              ws : []
            }
        },
      created() {
          this.ws = new WebSocket('ws://127.0.0.1:8000/api/test_ws')
          this.ws.onmessage = this.update_time
      },
      methods:{
          update_time(e){
            this.now_time = JSON.parse(e.data).time
          }
      }
    }
</script>

<style scoped>

</style>
